﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once

#include "GcmpDevService.h"
#include <iostream>
#include "FilePath.h"

namespace gcmp
{
    class GCMP_DEV_SERVICE_EXPORT FilePathManager
    {
        CANNOT_COPY_OR_ASSIGN(FilePathManager)
    public:
        static FilePathManager* Get();

        ~FilePathManager(void);

        //不在FilePathManager构造时直接初始化，是由于必须保证先
        //FilePathManager::Get()->SetBehaviorConfigFilePath(),再根据BehaviorConfig初始化各类路径
        void Initialize();

        // 不允许随便设置PublishConfigFile的路径
        const FilePath& GetPublishConfigFilePath();

        const FilePath& GetBehaviorConfigFilePath();
        // 必须在外部程序启动时设置相应BehaviorConfig文件路径
        void SetBehaviorConfigFilePath(const std::wstring& behaviorConfigFilePath);

        const FilePath& GetLogsFolderPath();
        void SetLogsFolderPath(const std::wstring& logsFolderPath);

        const FilePath& GetTemplateFolderPath();
        void SetTemplateFolderPath(const std::wstring& templateFolderPath);

        const FilePath& GetBatchGRepTestDataFolderPath();
        void SetBatchGRepTestDataFolderPath(const std::wstring& batchGRepTestDataFolderPath);

        const FilePath& GetGitRevisionFilePath();
        void SetGitRevisionFilePath(const std::wstring& gitRevisionFilePath);
    private:
        FilePathManager();
        void InitAppName();
        void InitPublishConfigFilePath();
        void InitLogsFolderPath();
        void InitTemplateFilePath();
        void InitBatchGRepTestDataFolderPath();
        void InitGitRevisionFilePath();

    private:
        std::wstring m_appName;
        FilePath m_publishConfigFilePath;
        FilePath m_behaviorConfigFilePath;
        FilePath m_logsFolderPath;
        FilePath m_templateFolderPath;
        FilePath m_batchGRepTestDataFolderPath;
        FilePath m_gitRevisionFilePath;

        bool m_isInitialled;
    };
}


